<template>
	<view v-if="height > 0" :style="'width: 100%; height: '+height+'px;'">
		<web-view ref="webView" style="width: 100%; height: 750upx;" :src="'http://www.ieater.uduemc.com/map/gaode-riding?' + query"></web-view>
	</view>
</template>

<script>
	export default {
		name: "g-map-riding",
		props: {},
		computed: {
			query() {
				return 'width=' + this.height + '&height=' + this.height + '&flng=' + this.from.lng +
					'&flat=' + this.from.lat +
					'&tlng=' + this.to.lng +
					'&tlat=' + this.to.lat;
			}
		},
		data() {
			return {
				height: 0,
				top: 0,
				from: {
					lng: 0,
					lat: 0
				},
				to: {
					lng: 0,
					lat: 0
				}
			}
		},
		methods: {
			show(hgh, top, _from, to) {
				this.from = _from
				this.to = to
				this.height = parseInt(hgh)
				this.top = parseInt(top)
				this.$nextTick(() => {
					// #ifdef APP-PLUS
					var currentWebview = this.$parent.$scope.$getAppWebview() //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效，非v3编译模式使用this.$mp.page.$getAppWebview()
					var wv = currentWebview.children()[0]
					wv.setStyle({
						top: this.top,
						height: this.height,
						scalable: false //webview的页面是否可以缩放，双指放大缩小
					})
					// #endif

					// #ifdef H5
					this.$refs.webView.$el.style.top = this.top + "px";
					// #endif
				})
			}
		}
	}
</script>

<style scoped lang="scss">
</style>
